home *** CD-ROM | disk | FTP | other *** search
/ Visual Basic Graphics Programming (2nd Edition) / Visual Basic Graphics Programming 2nd Edition.iso / OldSrc / CH6 / SRC / CIRCLE1.FRM (.txt) < prev    next >
Encoding:
Visual Basic Form  |  1996-03-28  |  3.8 KB  |  138 lines

  1. VERSION 4.00
  2. Begin VB.Form CircleForm 
  3.    Caption         =   "Circle 1"
  4.    ClientHeight    =   5310
  5.    ClientLeft      =   2175
  6.    ClientTop       =   930
  7.    ClientWidth     =   4830
  8.    Height          =   6000
  9.    Left            =   2115
  10.    LinkTopic       =   "Form1"
  11.    ScaleHeight     =   354
  12.    ScaleMode       =   3  'Pixel
  13.    ScaleWidth      =   322
  14.    Top             =   300
  15.    Width           =   4950
  16.    Begin VB.TextBox DtText 
  17.       Height          =   285
  18.       Left            =   2160
  19.       TabIndex        =   6
  20.       Text            =   "0.1"
  21.       Top             =   45
  22.       Width           =   615
  23.    End
  24.    Begin VB.TextBox TminText 
  25.       Height          =   285
  26.       Left            =   0
  27.       TabIndex        =   4
  28.       Text            =   "0"
  29.       Top             =   45
  30.       Width           =   615
  31.    End
  32.    Begin VB.CommandButton CmdGo 
  33.       Caption         =   "Go"
  34.       Default         =   -1  'True
  35.       Height          =   375
  36.       Left            =   4200
  37.       TabIndex        =   3
  38.       Top             =   0
  39.       Width           =   615
  40.    End
  41.    Begin VB.TextBox TmaxText 
  42.       Height          =   285
  43.       Left            =   1200
  44.       TabIndex        =   2
  45.       Text            =   "6.2832"
  46.       Top             =   45
  47.       Width           =   615
  48.    End
  49.    Begin VB.PictureBox Canvas 
  50.       AutoRedraw      =   -1  'True
  51.       Height          =   4815
  52.       Left            =   0
  53.       ScaleHeight     =   -2.2
  54.       ScaleLeft       =   -1.1
  55.       ScaleMode       =   0  'User
  56.       ScaleTop        =   1.1
  57.       ScaleWidth      =   2.2
  58.       TabIndex        =   0
  59.       Top             =   480
  60.       Width           =   4815
  61.    End
  62.    Begin VB.Label Label1 
  63.       Caption         =   "dt"
  64.       Height          =   255
  65.       Index           =   1
  66.       Left            =   1920
  67.       TabIndex        =   5
  68.       Top             =   60
  69.       Width           =   255
  70.    End
  71.    Begin VB.Label Label1 
  72.       Caption         =   "<= t <="
  73.       Height          =   255
  74.       Index           =   0
  75.       Left            =   645
  76.       TabIndex        =   1
  77.       Top             =   60
  78.       Width           =   495
  79.    End
  80.    Begin VB.Menu mnuFile 
  81.       Caption         =   "&File"
  82.       Begin VB.Menu mnuFileExit 
  83.          Caption         =   "E&xit"
  84.       End
  85.    End
  86. Attribute VB_Name = "CircleForm"
  87. Attribute VB_Creatable = False
  88. Attribute VB_Exposed = False
  89. Option Explicit
  90. Const PI = 3.14159
  91. ' ************************************************
  92. ' Draw the curve on the indicated picture box.
  93. ' ************************************************
  94. Sub DrawCurve(pic As PictureBox, start_t As Single, stop_t As Single, dt As Single)
  95. Dim x1 As Single
  96. Dim y1 As Single
  97. Dim t As Single
  98.     x1 = X(start_t)
  99.     y1 = Y(start_t)
  100.     pic.Cls
  101.     pic.CurrentX = x1
  102.     pic.CurrentY = y1
  103.     t = start_t + dt
  104.     Do While t < stop_t
  105.         x1 = X(t)
  106.         y1 = Y(t)
  107.         pic.Line -(x1, y1)
  108.         t = t + dt
  109.     Loop
  110.     x1 = X(stop_t)
  111.     y1 = Y(stop_t)
  112.     pic.Line -(x1, y1)
  113. End Sub
  114. ' ************************************************
  115. ' The parametric function Y(t).
  116. ' ************************************************
  117. Function Y(t As Single) As Single
  118.     Y = Sin(t)
  119. End Function
  120. ' ************************************************
  121. ' The parametric function X(t).
  122. ' ************************************************
  123. Function X(t As Single) As Single
  124.     X = Cos(t)
  125. End Function
  126. Private Sub CmdGo_Click()
  127. Dim tmin As Single
  128. Dim tmax As Single
  129. Dim dt As Single
  130.     tmin = CSng(TminText.Text)
  131.     tmax = CSng(TmaxText.Text)
  132.     dt = CSng(DtText.Text)
  133.     DrawCurve Canvas, tmin, tmax, dt
  134. End Sub
  135. Private Sub mnuFileExit_Click()
  136.     Unload Me
  137. End Sub
  138.